home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / ted5.zip / TED5.H < prev    next >
C/C++ Source or Header  |  1994-02-16  |  9KB  |  357 lines

  1. #define IDSTRING    "TED5v1.0"
  2. #define TITLESTR    "TED5 vD.IP"
  3. #define IDSTSTR        "         "TITLESTR
  4.  
  5. #include <stdio.h>
  6. #include <process.h>
  7. #include <io.h>
  8. #include <dos.h>
  9. #include <alloc.h>
  10. #include <dir.h>
  11. #include <mem.h>
  12. #include <string.h>
  13. #include <stdlib.h>
  14. #include <conio.h>
  15. #include <fcntl.h>
  16. #include "lib.h"
  17. #include "memmgr.h"
  18. #include "menu.h"
  19. #include "jhuff.h"
  20. #include "xms.h"
  21.  
  22. #define    SGN(x)        (x>0?1:x<0?-1:0)
  23. #define    OFF3(m,i)    (*(long huge *)((char huge *)m+(i)*3)&0xffffff)
  24.  
  25.  
  26. //
  27. // Defs for TED5
  28. //
  29.  
  30. typedef enum {TILES,MASKED,ICONS} screentype;
  31. typedef enum {DATA,CODE,FARDATA} segtype;    // FOR MAKEOBJ ONLY
  32.  
  33. #define SCindex        0x3C4
  34. #define SCmapmask    2
  35. #define GCindex        0x3CE
  36. #define GCreadmap    4
  37. #define GCmode        5
  38. #define crtcaddr    0x3d4
  39.  
  40. //
  41. // STRUCTURE OF TED5 TEMPFILE WHILE LAUNCHING
  42. //
  43. typedef struct {
  44.         video lastmode;
  45.         char ext[4];
  46.            } TempStruct;
  47.  
  48. //
  49. // STRUCTURE OF THE "TEDINFO.EXT" FILE THAT TED5 CREATES
  50. //
  51. typedef struct {
  52.         int level,lastvid,lastx,lasty,tsize;
  53.         int OldCgaXMS,OldEgaXMS,OldVgaXMS;
  54.         long OldCgaXMSsize,OldEgaXMSsize,OldVgaXMSsize;
  55.         int CgaXMSlook,EgaXMSlook,VgaXMSlook;
  56.         char permicon,pflags;
  57.         int oscrx,oscry;
  58.         char parmstring[64],launchname[14];
  59.         char BackgndColor;
  60.         char ImportPath[64];
  61.            } InfoStruct;
  62.  
  63. //
  64. // STRUCTURE OF THE "GFXINFO?.EXT" FILE THAT IGRAB CREATES
  65. //
  66. typedef struct {
  67.          int num8,num8m,num16,num16m,num32,num32m;
  68.          int off8,off8m,off16,off16m,off32,off32m;
  69.          int numpics,numpicm,numsprites;
  70.          int offpic,offpicm,offsprites;
  71.          int offpicstr,offpicmstr,offsprstr;
  72.          int numexterns,offexterns;
  73.            } GfxStruct;
  74.  
  75. //
  76. // TED5 LOADS & SAVES THIS HEADER FOR INTERNAL MAPFILE USAGE
  77. //
  78. typedef struct { unsigned maptype;    //bit 0=bkgnd/1=frgnd/2=info
  79.          unsigned tsize;    //1=8/2=16/3=32
  80.  
  81.          unsigned numtplanes,oldtilenum;
  82.          long tileinfooff[10];
  83.          unsigned tileinfolen[10];
  84.          char tnames[10][8];
  85.  
  86.          unsigned numtmplanes,oldtilemnum;
  87.          long tileinfomoff[10];
  88.          unsigned tileinfomlen[10];
  89.          char tmnames[10][8];
  90.  
  91.          unsigned RLEWtag;
  92.          long dataoffsets[100];
  93.          long datalengths[100];
  94.  
  95.          int NumIconRows;
  96.            } MapFileHeaderStr;
  97.  
  98. //
  99. // TED5 SAVES THIS MAPFILE HEADER FOR THE GAME
  100. //
  101. typedef struct {
  102.          unsigned RLEWtag;
  103.          long dataoffsets[100];
  104.  
  105.            } OutputHeadStr;
  106.  
  107. //
  108. // EACH AND EVERY MAP HAS THIS HEADER (IF THE MAP EXISTS)
  109. //
  110. typedef struct { long mapbkgndpl;
  111.          long mapfrgndpl;
  112.          long mapinfopl;
  113.          unsigned mapbkgndlen;
  114.          unsigned mapfrgndlen;
  115.          unsigned mapinfolen;
  116.          unsigned width,height;
  117.          char name[16];
  118.            } MapHeaderStr;
  119.  
  120. //
  121. // SPECIFY WHAT, WHEREFROM, AND HOW TO COPY A REGION
  122. //
  123. typedef struct {
  124.          char PlanesCopied;    // use BPLANE,FPLANE,IPLANE to mask
  125.          int MapOrTileSelect;    // 0:map,1:tileselect
  126.          int x,y,w,h;        // from map or tileselect
  127.            } CopyStr;
  128.  
  129. //
  130. // UNDO REGION
  131. //
  132. typedef struct {
  133.         int x,y,w,h;
  134.            } UndoStr;
  135.  
  136. //
  137. // LAST-BUILT "VIEWMAP"
  138. //
  139. typedef struct {
  140.         unsigned step,built_flag,EGAseg,maxpack;
  141.            } VMapStr;
  142.  
  143.  
  144. //
  145. // HEADER FOR APPLE-PREFERRED FILES
  146. //
  147. typedef struct { long length;
  148.          char Kind[5];
  149.          int MasterMode;
  150.          int PixelsPerLine;
  151.          int NumColorTables;
  152.          int ColorTable[16];
  153.          int NumScanLines;
  154.            } ApPrefStr;
  155.  
  156. #define CREATED        1
  157. #define NOTCREATED     2
  158. #define ANYLIST        3
  159.  
  160. #define BPLANE        1
  161. #define FPLANE        2
  162. #define IPLANE        4
  163.  
  164. #define O_FGNDBACK    4
  165. #define ICONBACK    3
  166.  
  167. #define TINFOWIDTH    3
  168. #define TINFOHEIGHT    7
  169. #define TINFOHEIGHTEGA2    25
  170.  
  171. extern MBarDef TED5MenuBar[];
  172. extern DialogDef DoCreated;
  173.  
  174. extern UndoStr UndoRegion;
  175. extern CopyStr TileCopy;
  176. extern MapFileHeaderStr _seg *MapFileHeader;
  177. extern char _seg *Tinfo[10],_seg *TMinfo[10],_seg *GraphHeader;
  178. extern long _seg *XMSlookup,_seg *CgaXMSlookup,_seg *EgaXMSlookup,_seg *VgaXMSlookup;
  179. extern int _seg *MapBkgnd,_seg *MapFrgnd,_seg *MapInfoPl,
  180.     _seg *CutBkgnd,_seg *CutFrgnd,_seg *CutInfoPl;
  181. extern MapHeaderStr MapHeader;
  182.  
  183. #if 0
  184. extern char far TOM;    // JOKE SHIT!
  185. #endif
  186.  
  187. extern TempStruct LaunchInfo;
  188. extern InfoStruct _seg *TEDInfo;
  189. extern GfxStruct _seg *GfxInfo;
  190. extern video lastvideo,videomode;
  191. extern screentype whichscreen;
  192. extern VMapStr VMapData;
  193.  
  194. extern char launchname[64],ext[4],format[2],projname[64],mapname[64],planes,
  195.     infoname[64],mapheadname[64],tdata,MapNames[100][16],parmstring[64];
  196. extern char SM_name[64],SM_loadname[64],BkgndColor;
  197.  
  198. extern unsigned temp,whichmap,numtplanes,tilenum,tilemnum,numtmplanes,left,
  199.     DirtyFlag,tilelen,tilemlen,whicht,whichtm,whichi,
  200.     tsize,infoy,infomaxw,mapwidth,mapheight,screenw,usingbat,
  201.     screenh,planeton,planemon,planeion,maxiconrows,lasticon,firsticon,
  202.     viewton,viewmon,viewion,XMSundoB,XMSundoF,XMSundoI,XMSmaps,
  203.     EgaXMS,CgaXMS,VgaXMS,xmshandle,GridMode,SnapMode,snapx,snapy,
  204.     snapxsize,snapysize,writeH,F3_flag,NoAbout;
  205. extern int tilebase,tilembase,infobaron,xbase,ybase,scrnbot,scrnrgt,
  206.     FillMode,PasteMode,SelectMode,SelX1,SelY1,PasteOK,SelX2,SelY2,pixelx,pixely,
  207.     selectcols,px,py,lastmap,TIybase,TIymbase,TIxbase,TIxmbase,BfillMode,
  208.     Plotting,TsearchMode;
  209. extern long CgaXMSsize,EgaXMSsize,VgaXMSsize;
  210.  
  211. extern void far *XMSdriver;
  212.  
  213. //
  214. // FUNCTION PROTOTYPES
  215. //
  216.  
  217. //
  218. // LIB_A.ASM
  219. //
  220. extern void CGAcharout(int x,int y,char ch);
  221. extern void EGAcharout(int x,int y,char ch,video vid);
  222. extern void VGAcharout(int x,int y,char ch);
  223.  
  224. //
  225. // TED5_A.ASM
  226. //
  227. extern unsigned EGA1lookup[200];
  228. extern unsigned EGA2lookup[200];
  229. extern void DrawTile(int x,int y,int tile);
  230. extern void CopyCGA(int srcx,int srcy,int width,int height,int destx,int desty);
  231. extern void CopyEGA(int srcx,int srcy,int width,int height,int destx,int desty);
  232. extern void CopyVGA(int srcx,int srcy,int width,int height,int destx,int desty);
  233. extern void Overlay(int tsize);
  234.  
  235. //
  236. // TED5
  237. //
  238. void FindGraphFile(void);
  239. void HandleEvent(void);
  240. void Continuous(void);
  241. void LoadInfoFile(void);
  242. int  LoadGraphStuff(int rtn,video newvid);
  243. void LoadMapHeader(void);
  244. void ParseCmdline(void);
  245. void InitTed5(void);
  246. void CallDesktop(void);
  247. void SelectTiles(int screen);
  248. void STnot(int x,int y);
  249. void DrawProjBord(int x,int y);
  250. void DrawInfoBar(void);
  251. void PrintCoords(void);
  252. void FigureScreenEdges(void);
  253. void errsound(void);
  254. void DrawMap(void);
  255. void CheckSelectEdges(int x,int y,int i,int j);
  256. int  InputIconAmount(void);
  257.  
  258. //
  259. // TED5-1
  260. //
  261. void Item_InputInfoplane(void);
  262. void Item_SelectTile(void);
  263. void Item_EditTinfoNames(void);
  264. void Item_BlockFill(void);
  265. void Item_TileSearch(void);
  266. void Item_Launch(void);
  267. void Item_Undo(void);
  268. void Item_TINFOCopy(void);
  269.  
  270. void CreateMap(int exitok);
  271. int  SelectMap(int exitok,int createflg,char *title);
  272. int  PickMorePlanes(void);
  273. void DoBlockFill(void);
  274. void RemoveUndoBuffers(void);
  275. void AllocateUndoBuffers(void);
  276. void RestoreUndo(void);
  277. void SaveUndo(int x,int y,int w,int h);
  278. void CopyUndoRegion(void);
  279. void SaveOutputHeader(void);
  280. void SaveTEDInfo(void);
  281. void BackupFile(char *filename);
  282.  
  283. void TInfoNon(int x,int y,int b);
  284. void TInfoNoff(int x,int y,int b);
  285. void TInfoMNon(int x,int y,int b);
  286. void TInfoMNoff(int x,int y,int b);
  287. void TIDoneOn(int x,int y);
  288. void TIDoneOff(int x,int y);
  289.  
  290.  
  291. //
  292. // TED5-2
  293. //
  294. void Item_About(void);
  295. void Item_ModeSwitch(void);
  296. void Item_DeleteMap(void);
  297. void Item_EditMap(void);
  298. void Item_SaveMap(void);
  299. void Item_CreateMap(void);
  300. void Item_Quit(void);
  301. void Item_MapStats(void);
  302. void Item_ToggleInfo(void);
  303. void Item_Amputate(void);
  304. void Item_SwitchMap(void);
  305. void Item_EditMapNames(void);
  306. void Item_Copy(void);
  307. void Item_Paste(void);
  308. void Item_LastVideo(void);
  309. void Item_FloodFill(void);
  310. void Item_LastMap(void);
  311. void Item_CountTiles(void);
  312. int  CheckForMapSave(void);
  313. void DoFloodFill(int x,int y,int whichb);
  314.  
  315. void DrawTileSelect(int deltarows,int *numrows,int *numcols);
  316. void DrawUnused(int deltarow);
  317. void DrawCurrentTiles(void);
  318. void ZeroModes(void);
  319.  
  320. //
  321. // TED5-3
  322. //
  323. void Item_EditMapEdges(void);
  324. void Item_PrintMem(void);
  325. void Item_Huffman(void);
  326. void CheckInfoValues(int i,int j,int tilei);
  327. void PrintMem(int x,int y);
  328. void EraseFloatPaste(void);
  329. void DrawFloatPaste(void);
  330. void CopyScreen(int srcx,int srcy,int width,int height,int destx,int desty);
  331. void Item_LAUNCHname(void);
  332. void Item_PARMstring(void);
  333. void Item_ChangeIconRows(void);
  334. void Item_ChangeLaunchIcon(void);
  335. void Item_ChangeBkgndColor(void);
  336.  
  337. //
  338. // TED5-4
  339. //
  340. void SignalSound(void);
  341. void Item_GraphicDump(void);
  342. void Item_EditTinfoValues(void);
  343. void Item_ProjectReSelect(void);
  344. void Item_AddDelTinfo(void);
  345. void Item_GridMode(void);
  346. void Item_SnapTog(void);
  347. void Item_ViewMap(void);
  348. void Item_ReviewMap(void);
  349. void Item_ImportMaps(void);
  350. void Item_VisitDOS(void);
  351. void Item_POtog(void);
  352. void Do_ViewMap(int how);
  353. int  MakeOBJ(char *filename,char *destfilename,char *public,segtype whichseg,char *farname);
  354. void DrawTinfoScreen(int thescreen,int deltax,int deltay);
  355. void EnterTinfoValue(int whichtinfo,int mx,int my,int H_or_V);
  356. void UseTinfoValue(int whichtinfo,int mx,int my,int PickupOrDrop);
  357.